<template>
	<view>
		<uni-nav-bar left-icon="icon-arrow-left-bold" backgroundColor="#ffffff" title="微信授权" style="border:none">
		</uni-nav-bar>
		<view v-if="isCanUse" class="weixinBody">
			<view>
				<view class='header'>
					<image src="/static/weixin.png" class="headerImg"></image>
				</view>
				<view class='content'>
					<view>申请获取以下权限</view>
					<text>获得你的公开信息(昵称，头像、地区等)</text>
				</view>
				<button class='bottom' @click="wxGetUserInfo">授权登录</button>
			</view>
		</view>
	</view>
</template>

<script>
	import publics from '@/components/publics'
	export default {
		data() {
			return {
				isCanUse: true,
				address: '',
				loginInfo: '',
				loginData: uni.getStorageSync('loginInfo_key'),

			};
		},
		onLoad(data) { //默认加载
			this.initLogin()
		},
		methods: {
			initLogin() {
				//#ifdef MP-WEIXIN
				this.address = publics.addressObtain()
				//#endif
			},
			wxGetUserInfo() {
				if (this.loginData) {
					uni.switchTab({
						url: '/pages/index/index'
					});
				} else {
					//#ifdef MP-WEIXIN
					this.loginInfo = publics.loginObtain()
					//#endif
					//#ifdef H5

					//#endif
				}
			}
		}
	}
</script>

<style>
	.weixinBody {
		display: flex;
		flex-direction: column;
	}

	.headerImg {
		width: 236rpx;
		height: 236rpx;
	}

	.header {
		margin: 90rpx 0 90rpx 50rpx;
		border-bottom: 1px solid #ccc;
		text-align: center;
		width: 650rpx;
		height: 300rpx;
		line-height: 450rpx;
	}

	.content {
		margin-left: 50rpx;
		margin-bottom: 90rpx;
	}

	.content text {
		display: block;
		color: #9d9d9d;
		margin-top: 40rpx;
	}

	.bottom {
		border-radius: 80rpx;
		margin: 70rpx 50rpx;
		font-size: 35rpx;
		background: #4CD964;
		color: #fff;
		letter-spacing: 4rpx;
	}
</style>
